package com.bluestone.context;

import java.util.ArrayList;
import java.util.List;

import com.bluestone.scripts.Command;
import com.bluestone.scripts.TestCase;

public class TestCaseContext extends ContextBase {
	public TestCaseContext(TestCase tc){	
		this.testcase = tc;
		this.setId(testcase.getId());
		this.createCommandContext();
	}
	private TestCase testcase = null;
	
	public TestCase getTestcase() {
		return testcase;
	}

	private void createCommandContext(){
		List commands = testcase.getCommands();
		for(int i=0; i< commands.size(); i++){
			Command command = (Command)commands.get(i);
			command.setId(""+i);
			CommandContext context = new CommandContext(command);
			commandContexts.add(context);
			
		}
	}
	private ArrayList<CommandContext> commandContexts = new ArrayList<CommandContext>();
	
	public CommandContext getCommandContext(Command command){
		CommandContext context = null;
		for(int i=0; i<commandContexts.size(); i++){
			CommandContext temp = commandContexts.get(i);
			if(command.getId().equalsIgnoreCase(temp.getId())){
				context = temp;
				break;
			}
		}
		return context;
	}
	
	public ProjectContext getProjectContext(){
		return ProjectContext.getInstance(null);
	}



}
